const mongoose = require("../db");
const schema = new mongoose.Schema({
  userid: String, // 用户ID
  proid: String, // 商品ID
  createtime: { type: Date, default: Date.now }, // 收藏时间
});

// 创建复合索引，确保用户不能重复收藏同一商品
schema.index({ userid: 1, proid: 1 }, { unique: true });

module.exports = mongoose.model("Favorite", schema);